package com.behavioranalysis.flinkprogram.flink.ad;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple6;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <h3>flinkprogram</h3>
 * <p>${description}</p>
 * Created by yang on 20-2-14 下午8:58
 * updated by yang on 20-2-14 下午8:58
 */
public class Filtered2TupleMapFunction implements MapFunction<Tuple6<Long, String, String, String, String, String>, Tuple2<String, Long>> {
    private static final long serialVersionUID = 1L;
    @Override
    public Tuple2<String, Long> map(Tuple6<Long, String, String, String, String, String> value) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        Date date = new Date(value.f0);
        String datekey = format.format(date);
        String province = value.f1;
        String city = value.f2;
        long adid = Long.valueOf(value.f4);
        String key = datekey + "_" + province + "_" + city + "_" + adid;
        return new Tuple2<>(key, 1L);
    }
}
